<?php

require("top.ajax.php");

if(isset($_SESSION['user'])) {
    /* Supporter une association */
    if(isset($_POST['action']) && $_POST['action'] == "add") {
        if($_POST['user_id'] == $_SESSION['user']['id']) {
            if(sizeof($_SESSION['user']['soutien']) == 3) {
                echo "false";
            } else {
                $_SESSION['user']->addSoutien($_POST['association_id']);
            }
        }
    }

    /* Ne plus supporter une association */
    if(isset($_POST['action']) && $_POST['action'] == "del") {
        if($_POST['user_id'] == $_SESSION['user']['id']) {
            $_SESSION['user']->deleteSoutien($_POST['association_id']);
        }
    }
}

?>
